package org.jl.demo.util;

import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class FileUtil {

    public static final String FILE_SEPARATOR = FileSystems.getDefault().getSeparator();

    public static void createFile(String filePath, String fileName) {
        File outputDir = new File(filePath);
        if (!outputDir.exists()) {
            boolean result = outputDir.mkdirs();
        }
        File file = new File(filePath + FILE_SEPARATOR + fileName);
        if (!file.exists()) {
            try {
                boolean result = file.createNewFile();
            } catch (IOException ignored) {
            }
        }
    }

    public static void writeFile(String filePath, String fileName, String content) {
        try {
            Path outputDirPath = Paths.get(filePath, fileName);
            Files.write(outputDirPath, content.getBytes());
        } catch (IOException ignored) {
        }
    }
}
